<template>
    <el-dialog
      :title="title"
      :model-value="visible"
      :before-close="onClose"
      :destroy-on-close="true"
      append-to-body
      :width="width + 'px'"
      :close-on-click-modal="false"
    >
      <div class="container" :style="{ height: height + 'px' }">
        <!-- 内容展示到插槽里面 -->
        <slot name="content"></slot>
      </div>
      <template #footer>
        <span class="dialog-footer">
          <el-button type="danger" @click="onClose">取消</el-button>
          <el-button type="primary" @click="onConfirm">确定</el-button>
        </span>
      </template>
    </el-dialog>
  </template>
  <script setup lang="ts">
  //定义弹框属性的数据类型
  interface DialogProps{//接口通常用来定义数据类型
      title:string,//标题
      visible:boolean,//控制弹框的显示和隐藏
      width?:number
      height?:number
  }
  //接受父组件传递过来的值
  const props = withDefaults(defineProps<DialogProps>(), {
    title: '标题',
    visible:false,
    height:280,
    width:630
  })
  const emit = defineEmits(["onClose", "onConfirm"]);
  //定义弹框的关闭
  const onClose = () => {
    emit("onClose");
  };
  //定义弹框的确定
  const onConfirm = () => {
    emit("onConfirm");
  };
  
  </script>
  
  <style scope lang="scss">
  .container {
    overflow-x: initial;
    overflow-y: auto;
  }
  .el-dialog {
    border-top-left-radius: 7px !important;
    border-top-right-radius: 7px !important;
    .el-dialog__header {
      margin-right: 0x;
      border-top-left-radius: 7px !important;
      border-top-right-radius: 7px !important;
      background-color: #fff !important;
      display:grid;
       place-items:center;
      .el-dialog__title {
        color: #151414;
        font-size: 20px;
        font-weight: 600;
      }
    }
    .el-dialog__headerbtn {
      .el-dialog__close {
        color: #141313;
      }
    }
    .el-dialog__body {
      padding: 10px;
    }
    .el-dialog__footer {
      border-top: 1px solid #e8eaec !important;
      padding: 10px;
    }
  }
  </style>
    